package com.tiantian.quanminxiu.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tiantian.quanminxiu.R;
import com.tiantian.quanminxiu.model.RoomInfo;
import com.tiantian.quanminxiu.utils.APPUtils;

import java.util.ArrayList;

/**
 * Created by admin on 2016/1/14.
 */
public class AttentionListAdapter extends BaseQuickAdapter<RoomInfo>
{
    private Activity activity;

    public AttentionListAdapter(Activity activity) {
        super( R.layout.main_attention_item,new ArrayList<RoomInfo>());
        this.activity = activity;
    }


    @Override
    protected void convert(BaseViewHolder baseViewHolder, RoomInfo roomInfo) {
        baseViewHolder.setText(R.id.txtAnchorName, roomInfo.getAnchorName())
                .setText(R.id.txtLiveTitle, roomInfo.getTitle())
                .setText(R.id.txtAnchorContribution, roomInfo.getHeat() + "")
                .setImageResource(R.id.imgUserCover, 0)
                .setTag(R.id.vMain, roomInfo.getRoomId())
                .addOnClickListener(R.id.vMain)
                .setVisible(R.id.vMainHallItemLineL, baseViewHolder.getPosition() % 2 == 0)
                .setVisible(R.id.vMainHallItemLineR, baseViewHolder.getPosition() % 2 != 0)
                .setImageResource(R.id.imgUserCover, 0);

        baseViewHolder.getView(R.id.vMain).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                APPUtils.PhoneLook_To(activity, (int) v.getTag());
            }
        });

        APPUtils.displayImage(roomInfo.getImgUrl(), (ImageView) baseViewHolder.getView(R.id.imgUserCover),true);
    }


}
